package api;

import conf.App;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import utils.HttpClientUtil;
import utils.ResponseData;

import java.util.HashMap;
import java.util.Map;

public class UserApi {
    private static final Logger log = LoggerFactory.getLogger(UserApi.class);

    // 添加用户
    private static final String addUserUrl = App.BASE_URL + "/member/member/addUserSubmit";

    /**
     * 添加用户
     *
     * @param name  用户名
     * @param phone 手机号码
     * @param pwd   密码
     * @param rePwd 确认密码
     * @param role  用户角色[1:投资人；2:借款人]
     * @return 构建之后的响应数据
     */
    public ResponseData addUser(String name, String phone, String pwd, String rePwd, int role) throws Exception {
        log.info("name={} phone={} pwd={} rePwd={} role={}", name, phone, pwd, rePwd, role);
        Map<String, String> formParams = new HashMap<>();
        formParams.put("name", name);
        formParams.put("phone", phone);
        formParams.put("pwd", pwd);
        formParams.put("rePwd", rePwd);
        formParams.put("role", String.valueOf(role));
        return HttpClientUtil.post_form(addUserUrl, formParams);
    }


}
